package com.fullertontech.framework.fileupload.oss;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.fullertontech.framework.config.ConfigClient;
import com.fullertontech.framework.fileupload.FileUploadClientGroup;
import com.fullertontech.framework.global.GlobalUtils;

@Configuration
public class OssConfig {
  @Autowired
  private ConfigClient configClient;
  @Bean("ossFileUploadClientGroup")
  public FileUploadClientGroup ossClient() {
    String endpoint=configClient.getProperty("endpoint","");
    String accessKeyId=configClient.getProperty("accessKeyId","");
    String secretAccessKey=configClient.getProperty("secretAccessKey","");
    EnableOss enableOss=GlobalUtils.getAnnotation(EnableOss.class);
    FileUploadClientGroup fileUploadClientGroup=new OssClientGroup(endpoint,enableOss.bucketName(),accessKeyId, secretAccessKey);
    return fileUploadClientGroup;
  }
}
